package com.lcj.ssm.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.lcj.ssm.mapper.ForumMapper;
import com.lcj.ssm.po.Forum;
import com.lcj.ssm.po.ForumVO;
import com.lcj.ssm.po.PageMessage;
import com.lcj.ssm.service.ForumService;

public class ForumServiceImpl implements ForumService{

	@Autowired
	private ForumMapper forumMapper ;
	
	public int insertForum(Forum forum) throws Exception {
		if(forum !=null){
			return forumMapper.insert(forum);
		}
		return 0;
	}

	public int deleteForum(int id) throws Exception {
		if(id>0){
			return forumMapper.deleteByPrimaryKey(id);
		}
		return 0;
	}

	public int updateForum(Forum forum) throws Exception {
		if(forum!=null && forum.getId()!=null){
			return forumMapper.updateByPrimaryKeySelective(forum);
		}
		return 0;
	}

	public List<Forum> selectForumList(ForumVO forumvo) throws Exception {
		if(forumvo!=null){
			return forumMapper.selectForumList(forumvo);
		}
		return null;
	}

	public Forum selectForum(int id) throws Exception {
		if(id>0){
			return forumMapper.selectByPrimaryKey(id);
		}
		return null;
	}

	public int getTotalCount() {
		return forumMapper.selectTotalCount();
	}

	public List<Forum> getTopForumList() throws Exception {
		return forumMapper.selectTopForun();
	}

	public Forum getLastForum() throws Exception {
		return forumMapper.selectLastForum();
	}

	public List<Forum> getBestForum() throws Exception {
		return forumMapper.selectBestForum();
	}

}
